import api from './config'

// 收藏相关API接口
export const favoriteApi = {
  // 添加收藏
  addFavorite: (resourceId) => {
    return api.post(`/resources/${resourceId}/favorite`)
  },

  // 取消收藏
  removeFavorite: (resourceId) => {
    return api.delete(`/resources/${resourceId}/favorite`)
  },

  // 检查收藏状态
  checkFavoriteStatus: (resourceId) => {
    return api.get(`/resources/${resourceId}/favorite/status`)
  },

  // 获取用户收藏列表
  getUserFavorites: (params = {}) => {
    return api.get('/favorites', { params })
  },

  // 获取最近收藏的资源
  getRecentFavorites: (limit = 5) => {
    return api.get('/favorites/recent', { params: { limit } })
  },

  // 获取用户收藏数量
  getUserFavoriteCount: () => {
    return api.get('/favorites/count')
  },

  // 获取资源被收藏数量
  getResourceFavoriteCount: (resourceId) => {
    return api.get(`/resources/${resourceId}/favorite/count`)
  }
}

export default favoriteApi 